﻿using Occt;
using System.Drawing;

namespace Tx.OCC
{
    public static class OccColorEx
    {
        /// <summary>
        /// Colors the specified color.
        /// </summary>
        /// <param name="color">The color.</param>
        /// <returns>Color.</returns>
        public static Color ToSystemColor(this Quantity_Color color)
        {
            return Color.FromArgb((color.Red * 255).ToInt32(), (color.Green * 255).ToInt32(), (color.Blue * 255).ToInt32());
        }

        /// <summary>
        /// Colors the specified color name.
        /// </summary>
        /// <param name="colorName">Name of the color.</param>
        /// <returns>Color.</returns>
        public static Color ToSystemColor(this Quantity_NameOfColor colorName)
        {
            return ToSystemColor(new Quantity_Color(colorName));
        }

        /// <summary>
        /// Converts to color.
        /// </summary>
        /// <param name="colorName">Name of the color.</param>
        /// <returns>Quantity_Color.</returns>
        public static Quantity_Color ToColor(this Quantity_NameOfColor colorName)
        {
            return new Quantity_Color(colorName);
        }

        /// <summary>
        /// Converts to aspect.
        /// </summary>
        /// <param name="materialName">Name of the material.</param>
        /// <returns>Graphic3d_MaterialAspect.</returns>
        public static Graphic3d_MaterialAspect ToAspect(this Graphic3d_NameOfMaterial materialName)
        {
            return new Graphic3d_MaterialAspect(materialName);
        }

        /// <summary>
        /// Converts to quantitycolor.
        /// </summary>
        /// <param name="color">The color.</param>
        /// <returns>Quantity_Color.</returns>
        public static Quantity_Color ToQuantityColor(this Color color)
        {
            return new Quantity_Color(color.R / 255.0, color.G / 255.0, color.B / 255.0, Quantity_TypeOfColor.Quantity_TOC_sRGB);
        }
    }
}
